package com.mass.core.sys.file.service.impl;

import com.mass.core.sys.file.dao.FileInfoTempMapper;
import com.mass.core.sys.file.model.FileInfoTemp;
import com.mass.core.sys.file.service.FileInfoService;
import com.mass.core.sys.file.service.FileUploadService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * 文件信息service实现类</p>
 *
 * @author liwenjun
 * @version 1.0.0
 * @date 2016/11/23 13:04
 */
@Service
public class FileInfoServiceImpl implements FileInfoService {

    @Autowired
    private FileInfoTempMapper fileInfoMapper;
    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 根据ID查询数据信息.
     *
     * @param id                查询条件
     * @return
     */
    public FileInfoTemp getEntityById(Long id){
        return this.fileInfoMapper.getEntityById(id);
    }

    /**
     * 分页查询
     * @param fileInfo
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public List<FileInfoTemp> selectPageList(FileInfoTemp fileInfo, Integer pageIndex, Integer pageSize) {
        return fileInfoMapper.selectPageList(fileInfo,pageIndex,pageSize);
    }

    /**
     * 删除文件
     * @param id            文件信息ID
     * @return
     */
    public boolean deleteEntityById(Long id){
    	Integer number = this.fileInfoMapper.delete(id);
    	if(!ObjectUtils.isEmpty(number) && number > 0)
    		return true;
    	else
    		return false;
    }

}
